var status;
var text;
var selstatus = -1;
var itemList = new Array();
var inventoryType;
var deleteSlot;
var deleteQuantity;

function start() {
    status = -1;
    action(1, 0, 0)
}

function action(c, b, a) {
    if (c <= 0) {
        cm.dispose();
        return
    } else {
        if (c == 1) {
            status++
        } else {
            status--
        }
        if (status == 0) {
            text = "\t\t\t\t#e- 便捷功能 -#n\r\n\r\n#b";
            text += "\t\t\t#L0#回收包裹内指定道具#l\r\n";
            text += "\r\n\r\n\r\n\r\n";
            cm.askMenu(text)
        } else {
            if (selstatus == -1) {
                selstatus = a
            }
            switch (selstatus) {
                case 0:
                    deleteItemBySlot(a);
                    break;
                case 1:
                    cm.openNpc(cm.getNpc(), 501)
            }
        }
    }
}

function deleteItemBySlot(c) {
    if (status == 1) {
        text = "\t\t#e- 请选择要回收的道具类型 -#n\r\n\r\n#b";
        text += "\t\t\t\t#L1#装备栏#l\r\n";
        text += "\t\t\t\t#L2#消耗栏#l\r\n";
        text += "\t\t\t\t#L4#其它栏#l\r\n";
        text += "\t\t\t\t#L3#设置栏#l\r\n";
        text += "\t\t\t\t#L5#特殊栏#l\r\n";
        cm.askMenu(text)
    } else {
        if (status == 2) {
            inventoryType = c;
            var f = cm.getInventory(inventoryType).list();
            itemList = f.iterator();
            text = "\t\t#e- 请选择要回收的道具 -#n\r\n\r\n#b";
            var a = 1;
            var e = Array();
            while (itemList.hasNext()) {
                var d = itemList.next();
                e[d.getPosition()] = d.getItemId()
            }
            for (var b in e) {
                text += "#L" + b + "##v" + e[b] + "#";
                if (a > 1 && a % 5 == 0) {
                    text += "\r\n"
                }
                a++
            }
            cm.askMenu(text)
        } else {
            if (status == 3) {
                var d = cm.getInventory(inventoryType).getItem(c);
                deleteSlot = c;
                deleteQuantity = d.getQuantity();
                text = "#e确定要回收#r#v" + d.getItemId() + "##z" + d.getItemId() + "# " + deleteQuantity + "个 #k吗？";
                cm.sendNextPrev(text)
            } else {
                if (status == 4) {
                    cm.removeSlot(inventoryType, deleteSlot, deleteQuantity);
                    cm.sendOk("回收成功，祝你游戏愉快~");
                    status = 0
                }
            }
        }
    }
}
var status = -1;